home *** CD-ROM | disk | FTP | other *** search
Text File | 2002-03-03 | 2.7 KB | 124 lines | [TEXT/FB^e] |
- /*
- HTML Rendering Example
- Chris Stasny, 1 June 00
-
- Made into an INCL March 2001 Andy Pritchard
-
- Call HMTL from your programs and PG via FN dohtml (See below)
-
- */
- '
- INCLUDE "Tlbx HTML Rendering.Incl"
- '
- begin globals
- DIM gHRref AS LONG // heavily used HR reference
- DIM @gPort& AS LONG// "@" means don't use register
- DIM gResizeFlag // bool: window will be resized
- end globals
- '
- '~Utility Routines
- /*
- This routine sets the size of the HTML
- rendering rect so that it fits in the
- current grafport.
- */
- LOCAL
- DIM renderRect AS RECT
- DIM err
- LOCAL FN setHTMLrect
- gResizeFlag = _false
- renderRect = @gPort&.portRect%
- call OFFSETRECT(renderRect,1,0)
- call INSETRECT(renderRect,0,-1)
- err = FN HRSetRenderingRect(gHRref,renderRect)
- END FN
- /*
- Check to see if rencering is available.
- Create a new HR reference.
- Set up default values.
- Build a file spec to an HTML file.
- Render the file.
- */
- local
- dim spec as fsspec
- dim err,wTitle$
- local fn showLocalURL(theURL$,vRef%)
- long if fn HRHTMLRenderingLibAvailable
- err = fn HRNewReference(gHRref,_kHRRendererHTML32Type,gPort&)
- fn setHTMLrect
- long if fn FBmakefsspec(vRef%,0,theURL$,spec) = _noErr
- long if fn HRGoToFile(gHRref,spec,_false,_zTrue) = _noErr
- long if fn HRGetTitle(gHRref,wTitle$) = _noErr
- call setwtitle(gPort&,wTitle$)
- end if
- end if
- end if
- end if
- end fn
- /*
- On exit, dispose of the HR reference.
- */
- local
- dim err
- local fn terminate
- err = fn HRDisposeReference(gHRref)
- end fn
- '~'6
- _htmlInit=1
- _htmlOpen=2
- _htmlButton=3
- _htmlRefresh=4
- _htmlResize=6
- _htmlClose=7
- /*
- Control routine
-
- FN dohtml(_htmlInit) 'immediately after pGBuild(_windowAnyname)
- FN dohtml(_htmlOpen) 'immediately after FN dohtml(_htmlInit)
- - change this to point to your HTML file
- FN dohtml(_htmlButton) 'in Button action and Mouse actions for your windowclass
- FN dohtml(_htmlRefresh) 'in windowupdate for your windowclass
- FN dohtml(_htmlResize) 'in windowrefresh for your windowclass
- FN dohtml(_htmlClose) 'in windowclose for your windowclass
-
- */
- local fn dohtml(myaction)
- dim 63 fName$
- DIM ref,err,vRef%,rgn&
- select myaction
- '~'6
- case _htmlInit//init
- call GETPORT(gPort&)
- '~'6
- case _htmlOpen// _openItem
- 'Change to point to your local HTML file
- vRef% = SYSTEM(_aplvol)
- fName$ = "my_help_file.htm" 'original name, huh? :-)
- LONG IF fName$[0]
- FN showLocalURL(fName$,vRef%)
- END IF
- err = fn HRActivate(gHRref)// _wndActivate
- '~'6
- case _htmlButton
- long if fn HRIsHREvent(event)
- % event,0
- xelse
- if gResizeFlag then fn setHTMLrect
- end if
- '~'6
- case _htmlRefresh//_wndRefresh
- rgn& = fn newrgn
- call rectrgn(rgn&,gPort&.portRect%)
- err = fn HRdraw(gHRref,rgn&)
- call disposergn(rgn&)
- '~'6
- case _htmlResize//Resize
- fn setHTMLrect
- '~'6
- case _htmlClose// _wndClose
- fn terminate
- '~'6
- end select
- end fn
-
-